﻿<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>添加配置</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="/fate/css/oksub.css">
	<script type="text/javascript" src="/fate/js/okLoading.js"></script>
</head>
<body>
<div class="ok-body">
	<!--form表单-->
    <form class="layui-form layui-form-pane ok-form" id="configuration">
        <div class="layui-form-item">
            <label class="layui-form-label">配置的key</label>
            <div class="layui-input-block">
                <input type="text" name="Key" id="Key" placeholder="请输入配置的key" autocomplete="off" class="layui-input"
                       lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">配置的值</label>
            <div class="layui-input-block">
                <input type="text" name="Value" id="Value" placeholder="请输入配置的值" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">环境变量</label>
            <div class="layui-input-block">
                <select name="EnvironmentType" id="EnvironmentType">
                    <option value="0">测试</option>
                    <option value="1">预发</option>
                    <option value="1">正式</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属组</label>
            <div class="layui-input-block">
                <input type="text" name="Group" id="Group" placeholder="请输入所属组" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                 <textarea placeholder="请输入备注" name="Remark" id="Remark" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="add">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<!--js逻辑-->
<script src="/fate/js/layui.js"></script>
<script>
	layui.use(["element", "form", "laydate", "okLayer", "okUtils","jquery"], function () {
		let form = layui.form;
		let okLayer = layui.okLayer;
        let okUtils = layui.okUtils;
           let $ = layui.jquery;
        okLoading.close();

		form.on("submit(add)", function (data) {
            okUtils.ajax("api/Management/Configuration", "post", JSON.stringify({
                Key: $("#Key").val(), Value: $("#Value").val(), EnvironmentType: $("#EnvironmentType").val()
                , Group: $("#Group").val()
                , Remark: $("#Remark").val()
            }), true).done(function (response) {
				console.log(response);
				okLayer.greenTickMsg("添加成功", function () {
					parent.layer.close(parent.layer.getFrameIndex(window.name));
				});
			}).fail(function (error) {
				console.log(error)
			});
			return false;
		});
	});
</script>
</body>
</html>
